<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>用AJAX以JSON方式获取数据</title>
  <script type="text/javascript" src="jquery.min.js"></script>
</head>
<body>
<input type="button" value="通过AJAX获取多个Hero对象" id="sender">

<div id="messageDiv"></div>

<script>
  $('#sender').click(function(){
    var url="getManyServlet";
    $.post(
            url,
            function(data) {
              var heros = $.parseJSON(data);
              for(i in heros){
                var old = $("#messageDiv").html();
                var hero = heros[i];
                $("#messageDiv").html(old + "<br>"+hero.name+"   -----   "+hero.hp);
              }
            });
  });
</script>
</body>

</body>
</html>